
<template>
  <div>
    <input v-focus  v-color  type="text" v-if="showIpt" ref="ipt" placeholder="搜索框" />
    <button @click="showFocus">点击搜索</button>
    <h1 v-color="color">哈哈哈</h1>
    <button @click="color='red'">点击切换颜色</button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      showIpt: false,
      color:"gold",
    };
  },
  methods: {
    showFocus() {
      this.showIpt = true;
    },
  },
//   directives: {
//     focus: {
//       inserted(el) {
//         el.focus();
//       },
//     },
//   },
};
</script>

<style>
</style>